package logic

import (
	"context"
	"house/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCollectAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectAddLogic {
	return &CollectAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CollectAddLogic) CollectAdd(req *types.CollectAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	collect, err := l.svcCtx.HouseSrv.CollectAdd(l.ctx, &house.CollectAddRequest{
		UserId:   req.UserId,
		Collects: req.Collects,
		HouseId:  req.HouseId,
	})
	if err != nil {
		return &types.Response{
			Code:     500,
			Messages: err.Error(),
			Data:     nil,
		}, nil
	}

	return &types.Response{
		Code:     200,
		Messages: "收藏成功",
		Data:     collect,
	}, nil
}
